Repository navigation
fix: add husky install fallback - #591
Merged
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
I fixed the Husky install path that was causing sh: husky: not found.
The old prepare script ran husky install exit 0. That avoided failing the install, but it still printed the shell
error first when Husky was not installed.
I moved that logic into .husky/install.mjs so Husky is skipped cleanly in production, CI, HUSKY=0, and installs where
the Husky package is not available.
I also updated the Dockerfiles so .husky/install.mjs is copied before npm install runs.
Related Issue
Fixes #328
Motivation and Context
Husky is only needed for local git hooks. It should not make production, CI, or Docker installs look broken when dev
dependencies are missing.
This keeps local hook setup working, but avoids the noisy sh: husky: not found message in environments where Husky
should be skipped.
How Has This Been Tested?
I verified the script syntax:
node --check .husky/install.mjs
I verified the skip paths:
NODE_ENV=production npm run prepare --silent
CI=true npm run prepare --silent
HUSKY=0 npm run prepare --silent
npm_config_omit=dev npm run prepare --silent
All commands completed successfully without printing the Husky error.
I also checked the old behavior still reproduces the original issue:
sh -c 'husky install exit 0'
It prints:
sh: 1: husky: not found
Screenshots (if appropriate):
Types of changes
Checklist: